FROM nvidia/cuda:12.1-runtime-ubuntu22.04

# 设置时区
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

# 更换为清华源
RUN sed -i 's/archive.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list && \
    sed -i 's/security.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list

# 安装系统依赖
RUN apt-get update && \
    apt-get install -y \
    ffmpeg \
    python3 \
    python3-pip \
    python3-venv \
    git \
    wget \
    curl \
    && rm -rf /var/lib/apt/lists/*

# 创建符号链接
RUN ln -sf /usr/bin/python3 /usr/bin/python

# 设置工作目录
WORKDIR /app

# 复制后端代码
COPY ./backend /app

# 设置环境变量
ENV HF_ENDPOINT=https://hf-mirror.com
ENV PYTHONPATH=/app
ENV PYTHONUNBUFFERED=1

# 安装Python依赖
RUN pip install --no-cache-dir -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt

# 创建必要的目录
RUN mkdir -p /app/note_results /app/static/screenshots /app/logs

# 暴露端口
EXPOSE 8483

# 启动命令
CMD ["python", "main.py"]
